#pragma once


#include "Core/Core.h"
#include "Events/Event.h"
#include "Events/ApplicationEvent.h"
#include "Core/Window.h"
#include "Renderer/Shader.h"
#include "Core/LayerStack.h"
#include "Renderer/Buffer.h"
#include "Renderer/VertexArray.h"
#include "Renderer/OrthographicCamera.h"
#include "ImGui/ImGuiLayer.h"
/*
 * 执行循环的主类
 * 初始化window, 把m_ImGuiLayer push到layer栈里
 * 绑定event的回调函数到window里如果window触发按键就回调这个event方法
 * 主循环里执行layer栈里的update方法和windows的update方法和layer->OnImGuiRender();
 * */
int main(int argc, char** argv);
namespace Hazel{
    class Application {
    public:
        Application();
        virtual ~Application();

        void CreateTest();
        void Test2();
        void Test3();
        void Test4();


        void OnEvent(Event& e);

        void PushLayer(Layer* layer);
        void PushOverlay(Layer* layer);

        inline Window& GetWindow() {return *m_Window;}
        inline static Application& Get() {return *s_Instance;}
        // unique_ptr 离开作用域销毁
//        std::unique_ptr<Shader> m_Shader;
        // 引用计数为0销毁
        Scope<VertexArray> m_VertexArray;
        Scope<Shader> m_Shader;
        Scope<VertexBuffer> m_VertexBuffer;
//        std::shared_ptr<IndexBuffer> m_IndexBuffer;
//        OrthographicCamera m_Camera;
//        std::shared_ptr<Shader> m_BlueShader;
    private:
        void Run();
        bool OnWindowClose(WindowCloseEvent& e);
        bool OnWindowResize(WindowResizeEvent& e);
        //std::unique_ptr  智能指针，自动释放内存
        Scope<Window>m_Window;
        ImGuiLayer* m_ImGuiLayer;
        bool m_Running = true;

        LayerStack m_LayerStack;
        float m_LastFrameTime = 0;
        bool m_Minimized = false;
    private:
        static Application* s_Instance;
        friend int ::main(int argc, char** argv);
    };

    Application* CreateApplication();
}
